<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .bigbox{
            text-align: center;
        }
        div{
            width: 100px;
            height: 100px;
            background-color: darkred;
            display: inline-block;
            margin: 10px;
        }
    </style>
</head>
<body>
    <nav class="bigbox">
        <button onclick="f1()">点击将div变成粉色</button>
        <br>
        <div></div>
        <div></div>
        <div></div>
    </nav>
</body>
</html>

<script>
    var c_div = document.querySelectorAll("div");

    function f1(){
        for(var i=0;i<c_div.length;i++){
            c_div[i].style.backgroundColor = "pink"
        }
       
    }
</script>